#ifndef 	__GSM_H__
#define		__GSM_H__	

#include "def.h"
#include "fifo.h"

typedef struct
{
	BYTE frameBuf[512];
	UINT16 frameLength;
}T_GSM_TX_INFO;

#ifndef 	_TBOX_GSM_
	#define		GSM_EXTERN		extern
	EXPORT_FIFO_API(GSMRxFifo,512,BYTE,UINT16)	
	EXPORT_FIFO_API(GSMTxFifo,3,T_GSM_TX_INFO,UINT16);
#else
	#define		GSM_EXTERN
	NEW_FIFO(GSMRxFifo,512,BYTE,UINT16)
	NEW_FIFO(GSMTxFifo,3,T_GSM_TX_INFO,UINT16);
#endif

#define  RSACERTIEXIST	0XAA
	
enum enumGSM
{
	gsmNone = 0x00,
	gsmError,
	gsmOK,
	gsmWait,
	gsmTimeOut = 0xFF
};

enum gsmRunStatus
{
	gsmWaitRun = 0x00,
	gsmResetRun,
	gsmWakeRun,
};

enum enumGSMProc
{
	gsmProcInit = 0,
	gsmStart, //1
	gsmWaitStart0,
	gsmWaitStart1,
	gsmWaitStart2,
	gsmWaitStart3,
	gsmAT,
	gsmATECHO,
	gsmATCFUNC0,
	gsmATCFUNC1,
	gsmATIMEI,
	gsmATCIMI,
	gsmATGMR,//10
	gsmATNCCID,
	gsmATNCDP,
	gsmATBAND,
	gsmATNCONFIG,
	gsmATCGDCONT0,
	gsmATCGDCONT1,
	gsmATCGPADDR,
	gsmATCGATT0,
	gsmATCGATT1,
	gsmATCREG0,
	gsmATCREG1,
	gsmATCSCON,
	gsmATCCLK,
	gsmATNNMI,
	gsmATNSMI,
	gsmATQURCCFG,
	gsmATQSCLK,
	gsmATCMGF, //
	gsmATCSCS,
	gsmATCNMI,
	gsmATCONNECT0,
	gsmATCONNECT1,
	gsmATCMD1,
	gsmATQSSLCOLSE,
	gsmATSTATE,
	gsmATFreeLoop,//21
	gsmATCSQ,
	gsmATRD0,
	gsmATRD1,
	gsmATWD0,
	gsmATWD1,
	gsmCLOSE,
	gsmSleep0,
	gsmSleep1,
	gsmSleep2,
	gsmSleep3,
	gsmSleep4,
	gsmWakeup,
	
};
enum SIMCARD
{
	ChinaMobile = 0,
	ChinaUnicom ,
};

typedef struct
{
	char cmpSrcStr[32];
	BYTE strlen;
}T_STRCMP_INFO;

typedef struct
{
	BOOL bAllGSMSleep;
	BOOL bConnectRervers;
	BOOL bAccStatus;
	char cmpStr[32];
	BYTE gsmPowerStatus;
	char IMEI[15 + 1];
	char IMSI[15 + 1];
	char ICCID[20+1];

	char onRecGSMFrameChData[512];
	UINT16 onRecGSMFrameChDataLength;
	
	BYTE onRecGSMFrameHexData[256];
	UINT16 onRecGSMFrameHexDataLength;
	BYTE atCmdStatus;
	
	char tempRecData[400];
	UINT16 tempRecDataLength;
	
	BYTE gsmConnectErrorCnt;
	UINT16 gsmRecFrameLength;
	T_GSM_TX_INFO gsmTxInfo;
	
	UINT32 gsmPowerDelayTimer;
	UINT32 gsmATCmdDelayTimer;
	T_STRCMP_INFO strcmpInfo[5];
	
	BYTE strcmpLength;
	BYTE whatSIMCardOperators;
	BYTE gsmWhatRunStatus;
	UINT16 gsmNBDataLength;
	UINT32 debugDelayTimer;
	
}T_GSM_TASK_INFO;


GSM_EXTERN T_GSM_TASK_INFO gsmTaskInfo;

GSM_EXTERN void gsmBoardInit(void);
GSM_EXTERN void gsmBoardDeInit(void);
GSM_EXTERN void gsmProc(void);
GSM_EXTERN void ipcEventGsmComm(ULONG enumWhatEvent,ULONG lPara,BYTE *p,UINT16 length);

#endif

